<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" session="false"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%--
- Author(s): Administrator
- Date: 2018-04-02 19:08:00
- Description:
    --%>
<head>
<title>我创建的bug</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<script src="<%=request.getContextPath()%>/common/nui/nui.js"
	type="text/javascript">
	
</script>
</head>
<body style="width: 98%; height: 95%;">
	<div class="nui-panel" title="Bug查询" iconCls="icon-add"
		style="width: 100%; height: 15%;" showToolbar="false"
		showFooter="true">
		<div id="form1" class="nui-form" align="center" style="height: 100%">
			<!-- 数据实体的名称 -->
			<input class="nui-hidden" name="criteria/_entity"
				value="com.zhmy.xmgl.ZHMY_BUG.ZhmyBug">
			<!-- 排序字段 -->
			<table id="table1" class="table" style="height: 100%">
				<tr>
					<td class="form_label">bug标题:</td>
					<td colspan="1"><input class="nui-textbox"
						name="criteria/_expr[1]/bugTitle" /> <input class="nui-hidden"
						name="criteria/_expr[1]/_op" value="like"> <input
						class="nui-hidden" name="criteria/_expr[1]/_likeRule" value="end">
					</td>
					<!-- <td class="form_label">项目名称:</td>
					<td colspan="1"><input class="nui-textbox"
						name="criteria/_expr[3]/zhmyProject.projectId" /> <input
						class="nui-hidden" name="criteria/_expr[3]/_op" value="=">
					</td> -->
					<td class="form_label">选择项目:</td>
					<td colspan="1"><input id="lookup2" onvaluechanged="onDeptChanged"
						name="criteria/_expr[3]/zhmyProject.projectId" class="nui-lookup"
						style="width: 125px;" textField="projectName"
						valueField="projectId" popupWidth="auto" popup="#gridPanel"
						grid="#datagridq" multiSelect="false" /> <input
						class="nui-hidden" name="criteria/_expr[3]/_op" value="=">

					</td>

					<td class="form_label">bug进度:</td>
					<td colspan="1"><input class="nui-dictcombobox"
						dictTypeId="TASK_STATUS" name="criteria/_expr[2]/bugStatus" /> <input
						class="nui-hidden" name="criteria/_expr[2]/_op" value="="></td>


					<!-- <td class="form_label">bug发布人:</td>
					<td colspan="1">
						<input class="nui-textbox"
						name="criteria/_expr[4]/bugFounder" />  <input id="lookpush"
						name="criteria/_expr[4]/bugFounder" class="nui-lookup"
						style="width: 125px;" textField="partyId" valueField="partyId"
						popupWidth="auto" popup="#popuppush" grid="#gridpush"
						multiSelect="false" /> <input class="nui-hidden"
						name="criteria/_expr[4]/_op" value="=">
					</td> -->


					<td class="form_label">bug接收人:</td>
					<td colspan="3">
						<!-- <input class="nui-textbox"
						name="criteria/_expr[5]/bugSendee" />  --> <input id="lookupdee"
						name="criteria/_expr[5]/bugSendee" class="nui-lookup"
						style="width: 125px;" textField="partyId" valueField="partyId"
						popupWidth="auto" popup="#gridPaneldee" grid="#datagridee"
						multiSelect="false" /> <input class="nui-hidden"
						name="criteria/_expr[5]/_op" value="=">
					</td>
					
					<td class="form_label">所属版本:</td>
					<td colspan="1"><input id="lookup7"
						name="criteria/_expr[8]/zhmyVersionChange.vcId" class="nui-lookup"
						textField="vcVersionNumber" valueField="vcId" popupWidth="auto"
						popup="#gridPanel7" grid="#datagrid7" multiSelect="false" /> <input
						class="nui-hidden" name="criteria/_expr[8]/_op" value="=">
					</td>
				</tr>
			</table>
		</div>
	</div>
	<!--footer-->
	<div property="footer" align="center">
		<a class="nui-button" onclick="search()"> 查询 </a> <a
			class="nui-button" onclick="reset()"> 重置 </a>
	</div>
	<div class="nui-panel" title="Bug列表" iconCls="icon-add"
		style="width: 100%; height: 85%;" showToolbar="false"
		showFooter="false">
		<div class="nui-toolbar" style="border-bottom: 0; padding: 0px;">
			<table style="width: 100%;">
				<tr>
					<td style="width: 100%;">
						<!-- <a class="nui-button"
						iconCls="icon-add" onclick="add()"> 增加 </a>  -->
						<a id="update" class="nui-button" iconCls="icon-edit"
						onclick="edit()"> 编辑 </a> <a class="nui-button"
						iconCls="icon-remove" onclick="remove()"> 删除 </a>
					</td>
				</tr>
			</table>
		</div>
		<div class="nui-fit">
			<div id="datagrid1" dataField="zhmybugs" class="nui-datagrid"
				style="width: 100%; height: 100%;"
				url="com.zhmy.xmgl.bug.zhmybugbiz.queryICreatedZhmyBugs.biz.ext"
				pageSize="10" showPageInfo="true" multiSelect="true"
				onselectionchanged="selectionChanged" allowSortColumn="false"
				ondrawcell="addLink">
				<div property="columns">
					<div type="indexcolumn"></div>
					<div type="checkcolumn"></div>

					<div field="bugTitle" headerAlign="center" allowSort="true">
						bug标题</div>
					<div field="bugLevel" headerAlign="center" allowSort="true"
						dicttypeid="URGENT_DEGREE" renderer="urgentDegree">bug紧急程度</div>
					<div field="bugStatus" headerAlign="center" allowSort="true"
						dicttypeid="TASK_STATUS" renderer="taskStatus">bug进度</div>
					<div field="zhmyProject.projectName" headerAlign="center"
						allowSort="true">项目名称</div>
					<!-- <div field="bugId" headerAlign="center" allowSort="true"
						visible="false">bug编号</div> -->
					<!-- <div field="bugContent" headerAlign="center" allowSort="true">
						bug内容</div> -->
					<!-- <div field="bugFounder" headerAlign="center" allowSort="true">
						bug发布人</div> -->
					<div field="bugSendee" headerAlign="center" allowSort="true">
						bug接收人</div>
					<div field="bugCtime" headerAlign="center" allowSort="true">
						bug创建时间</div>
					<div name="log" headerAlign="center">操作</div>

				</div>

			</div>
		</div>
	</div>
	</div>
	<div id="gridPanel" class="nui-panel" title="header" iconCls="icon-add"
		style="width: 450px; height: 250px;" showToolbar="true"
		showCloseButton="true" showHeader="false" bodyStyle="padding:0"
		borderStyle="border:0">
		<div property="toolbar"
			style="padding: 5px; padding-left: 8px; text-align: center;">
			<div style="float: left; padding-bottom: 2px;">
				<span>项目名称:</span> <input id="keyText" class="nui-textbox"
					style="width: 160px;" onenter="onSearchClick" /> <a
					class="nui-button" onclick="onSearchClick1">查询</a> <a
					class="nui-button" onclick="onClearClick1">清除</a>
			</div>
			<div style="float: right; padding-bottom: 2px;">
				<a class="nui-button" onclick="onCloseClick1">关闭</a>
			</div>
			<div style="clear: both;"></div>
		</div>
		<div id="datagridq" class="nui-datagrid"
			style="width: 100%; height: 100%;" borderStyle="border:0"
			showPageSize="false" showPageIndex="false" dataField="orgs"
			url="com.zhmy.xmgl.bug.zhmybugbiz.getProjectName.biz.ext">
			<div property="columns">
				<div type="checkcolumn"></div>
				<div field="projectId" width="120" headerAlign="center"
					allowSort="true">项目编码</div>
				<div field="projectName" width="120" headerAlign="center"
					allowSort="true">项目名称</div>
			</div>
		</div>
	</div>


	<div id="gridPaneldee" class="nui-panel" title="header"
		iconCls="icon-add" style="width: 450px; height: 250px;"
		showToolbar="true" showCloseButton="true" showHeader="false"
		bodyStyle="padding:0" borderStyle="border:0">
		<div property="toolbar"
			style="padding: 5px; padding-left: 8px; text-align: center;">
			<div style="float: left; padding-bottom: 2px;">
				<span>人员名称:</span> <input id="keyText2" class="nui-textbox"
					style="width: 160px;" onenter="onSearchClick" /> <a
					class="nui-button" onclick="onSearchClick3">查询</a> <a
					class="nui-button" onclick="onClearClick3">清除</a>
			</div>
			<div style="float: right; padding-bottom: 2px;">
				<a class="nui-button" onclick="onCloseClick3">关闭</a>
			</div>
			<div style="clear: both;"></div>
		</div>
		<div id="datagridee" class="nui-datagrid"
			style="width: 100%; height: 100%;" borderStyle="border:0"
			showPageSize="false" showPageIndex="false" dataField="orgs1"
			url="com.zhmy.xmgl.bug.zhmybugbiz.getPushUser.biz.ext">
			<div property="columns">
				<div type="checkcolumn"></div>
				<div field="partyId" width="120" headerAlign="center"
					allowSort="true">选择人员:</div>

			</div>
		</div>
	</div>
	
	<!--  look up 7 -->
	<div id="gridPanel7" class="nui-panel" title="header"
		iconCls="icon-add" style="width: 450px; height: 250px;"
		showToolbar="true" showCloseButton="true" showHeader="false"
		bodyStyle="padding:0" borderStyle="border:0">
		<div property="toolbar"
			style="padding: 5px; padding-left: 8px; text-align: center;">
			<div style="float: left; padding-bottom: 2px;">
				<span>接收人:</span> <input id="keyText7" class="nui-textbox"
					style="width: 160px;" onenter="onSearchClick7" /> <a
					class="nui-button" onclick="onSearchClick7">查询</a> <a
					class="nui-button" onclick="onClearClick7">清除</a>
			</div>
			<div style="float: right; padding-bottom: 2px;">
				<a class="nui-button" onclick="onCloseClick7">关闭</a>
			</div>
			<div style="clear: both;"></div>
		</div>
		<div id="datagrid7" class="nui-datagrid"
			style="width: 100%; height: 100%;" borderStyle="border:0"
			showPageSize="false" showPageIndex="false" dataField="orgs"
			url="com.zhmy.xmgl.zhmyprojectmanage.getVersionListOfProject.biz.ext">
			<div property="columns">
				<div type="checkcolumn"></div>
				<div field="vcVersionNumber" width="120" headerAlign="center"
					allowSort="true">版本名称</div>
			</div>
		</div>
	</div>
	





	<!-- <div id="popuppush" class="nui-panel" title="header" iconCls="icon-add"
		style="width: 450px; height: 250px;" showToolbar="true"
		showCloseButton="true" showHeader="false" bodyStyle="padding:0"
		borderStyle="border:0">
		<div property="toolbar"
			style="padding: 5px; padding-left: 8px; text-align: center;">
			<div style="float: left; padding-bottom: 2px;">
				<span>人员名称:</span> <input id="keyText3" class="nui-textbox"
					style="width: 160px;" onenter="onSearchClick" /> <a
					class="nui-button" onclick="onSearchClick4">查询</a> <a
					class="nui-button" onclick="onClearClick4">清除</a>
			</div>
			<div style="float: right; padding-bottom: 2px;">
				<a class="nui-button" onclick="onCloseClick4">关闭</a>
			</div>
			<div style="clear: both;"></div>
		</div>
		<div id="gridpush" class="nui-datagrid"
			style="width: 100%; height: 100%;" borderStyle="border:0"
			showPageSize="false" showPageIndex="false" dataField="orgs1"
			url="com.zhmy.xmgl.bug.zhmybugbiz.getPushUser.biz.ext">
			<div property="columns">
				<div type="checkcolumn"></div>
				<div field="partyId" width="120" headerAlign="center"
					allowSort="true">选择人员:</div>

			</div>
		</div>
	</div>
 -->











	<script type="text/javascript">
		nui.parse();
		var grid = nui.get("datagrid1");

		function taskStatus(e) {
			return nui.getDictText("TASK_STATUS", e.value);
		}
		function urgentDegree(e) {
			return nui.getDictText("URGENT_DEGREE", e.value);
		}

		var formData = new nui.Form("#form1").getData(false, false);
		grid.load(formData);
		
		
		var outProjectid = 1;
		
		//选择接收人关于项目联动的处理函数
		function onDeptChanged(e) {
			var projectid = nui.getbyName("criteria/_expr[3]/zhmyProject.projectId").getValue();
			
			//nui.get("lookup6").setText(fu_ze_ren);
			outProjectid = projectid;
			//console.log("projectid="+outProjectid);
			
		    var url = "com.zhmy.xmgl.zhmyprojectmanage.getVersionListOfProject.biz.ext?projectid="+projectid;
		   nui.get("datagrid7").setUrl(url);
		   onSearchClick7();
		}

		//新增
		/* function add() {
			nui.open({
				url : "ZhmyBugForm.jsp",
				title : "新增bug",
				width : 600,
				height : 300,
				onload : function() {//弹出页面加载完成
					var iframe = this.getIFrameEl();
					var data = {
						pageType : "add"
					};//传入页面的json数据
					iframe.contentWindow.setFormData(data);
				},
				ondestroy : function(action) {//弹出页面关闭前
					grid.reload();
				}
			});
		} */

		//编辑
		function edit() {
			var row = grid.getSelected();
			
			
			if (row) {
			var bug_status=row.bugStatus;
			
			
			if(bug_status > 2){
			nui.alert("已经接单bug不可修改");
			return;
			}
			
				nui.open({
					url : "<%=request.getContextPath()%>/xmgl/ZhmyBugForm.jsp",
					title : "修改bug",
					width : 1000,
					height : 650,
					onload : function() {
						var iframe = this.getIFrameEl();
						var data = {pageType:"edit",record:{zhmybug:row}};
                            //直接从页面获取，不用去后台获取
                           
						//直接从页面获取，不用去后台获取
						iframe.contentWindow.setFormData(data);
					},
					ondestroy : function(action) {
						grid.reload();
					}
				});
			
			
			
			
			} else {
				nui.alert("请选中一条记录", "提示");
			}
		}

		//删除
		 function remove() {
			var rows = grid.getSelecteds();
			if (rows.length > 0) {
				nui
						.confirm(
								"确定删除选中记录？",
								"系统提示",
								function(action) {
									if (action == "ok") {
										var json = nui.encode({
											zhmybugs : rows
										});
										grid.loading("正在删除中,请稍等...");
										$
												.ajax({
													url : "com.zhmy.xmgl.bug.zhmybugbiz.deleteZhmyBugs.biz.ext",
													type : 'POST',
													data : json,
													cache : false,
													contentType : 'text/json',
													success : function(text) {
														var returnJson = nui
																.decode(text);
														if (returnJson.exception == null) {
															grid.reload();
															nui
																	.alert(
																			"删除成功",
																			"系统提示",
																			function(
																					action) {
																			});
														} else {
															grid.unmask();
															nui.alert("删除失败",
																	"系统提示");
														}
													}
												});
									}
								});
			} else {
				nui.alert("请选中一条记录！");
			}
		} 

		//重新刷新页面
		function refresh() {
			var form = new nui.Form("#form1");
			var json = form.getData(false, false);
			grid.load(json);//grid查询
			nui.get("update").enable();
		}

		//查询
		function search() {
			var form = new nui.Form("#form1");
			var json = form.getData(false, false);
			grid.load(json);//grid查询
		}

		//重置查询条件
		function reset() {
			var form = new nui.Form("#form1");//将普通form转为nui的form
			form.reset();
		}

		//enter键触发查询
		function onKeyEnter(e) {
			search();
		}

		//当选择列时
		function selectionChanged() {
			var rows = grid.getSelecteds();
			if (rows.length > 1) {
				nui.get("update").disable();
			} else {
				nui.get("update").enable();
			}
		}

		var grid1 = nui.get("datagridq");
		var keyText1 = nui.get("keyText");
		grid1.load();
		function onSearchClick1(e) {
			grid1.load({
				key : keyText1.value
			});
		}

		function onCloseClick1(e) {
			var lookup2 = nui.get("lookup2");
			lookup2.hidePopup();
		}
		function onClearClick1(e) {
			var lookup2 = nui.get("lookup2");
			lookup2.deselectAll();
		}

		function onClenrClick1() {
			var lookup2 = nui.get("lookup2");
			lookup2.deselectAll();
		}

		var grid3 = nui.get("datagridee");
		var keyText3 = nui.get("keyText2");
		grid3.load();
		function onSearchClick3(e) {
			grid3.load({
				key : keyText3.value
			});
		}

		function onCloseClick3(e) {
			var lookup2 = nui.get("lookupdee");
			lookup2.hidePopup();
		}
		function onClearClick3(e) {
			var lookup2 = nui.get("lookupdee");
			lookup2.deselectAll();
		}

		function onClenrClick3() {
			var lookup2 = nui.get("lookupdee");
			lookup2.deselectAll();
		}
		
		
		 var grid7 = nui.get("datagrid7");
		var keyText7 = nui.get("keyText7");
		//grid5.load();
		grid7.load({
				key : keyText7.value ,
				projectid: outProjectid
			});
	 	function onSearchClick7(e) { 
			grid7.load({
				key : keyText7.value ,
				projectid: outProjectid
			});
		}
			
		function onCloseClick7(e) {
			var lookup2 = nui.get("lookup7");
			lookup2.hidePopup(); 
		}
			
		function onClearClick7() {
			var lookup2 = nui.get("lookup7");
			lookup2.deselectAll();
		}
	

		/* var grid4 = nui.get("gridpush");
		var keyText4 = nui.get("keyText3");
		grid4.load();
		function onSearchClick4(e) {
			grid4.load({
				key : keyText4.value
			});
		}

		function onCloseClick4(e) {
			var lookup2 = nui.get("lookpush");
			lookup2.hidePopup();
		}
		function onClearClick4(e) {
			var lookup2 = nui.get("lookpush");
			lookup2.deselectAll();
		}

		function onClenrClick4() {
			var lookup2 = nui.get("lookpush");
			lookup2.deselectAll();
		}
 */
		//查看日志列表
		function addLink(e) {
			if (e.column.name == "log") {
			
			    var rowline = e.row.bugId;
			    var bugStatus=e.row.bugStatus;
			    
			    
			    var style1 = "style='margin: 2px; background:#555555; color:#fff; text-align: center; display: inline-block; border-radius:8px; padding:4px 10px; border:none;'";
				var style2 = "style='margin: 2px; background:#008cba; color:#fff; text-align: center; display: inline-block; border-radius:8px; padding:4px 10px; border:none;'";
			    var style3 = "style='margin: 2px; background:#a7a7a7; color:#fff; text-align: center; display: inline-block; border-radius:8px; padding:4px 10px; border:none;'";
			    
			    var detailsButton = "<a><button "+style1+" onclick='openDetails("+rowline+")'>查看</button></a>";
			    /* var detailsButton = "<a style='color:#0000ff;text-decoration:underline;' ><button style='background:#0000cc; color:#fff;' onclick='openDetails("+rowline+")'>查看</button></a>"; */
			    if(bugStatus==4){
				/* e.cellHtml = "<a style='color:#1B3F91;text-decoration:underline;'><button onclick='hehe("+rowline+")'>完成</button></a>";
				e.cellHtml += detailsButton; */
				
				e.cellHtml = "<a><button "+style2+" onclick='hehe("+rowline+")'>完成</button></a>";
				e.cellHtml += detailsButton;
				
				
			    }else{
			    e.cellHtml = "<a><button "+style3+" disabled='disabled'>完成</button></a>";
											e.cellHtml += detailsButton;
			    
			    }
			}
		}
		function hehe(rowline) {
									
									
									var json = "{'rowLine':"+rowline+"}";
									/* console.log("json"+json); */
									
									$.ajax({
                                        url:"com.zhmy.xmgl.bug.zhmybugbiz.updateBugStatusDone.biz.ext",
                                        type:'POST',
                                        data:json,
                                        cache: false,
                                        contentType:'text/json',
                                        success:function(text){
                                            var returnJson = nui.decode(text);
                                            if(returnJson.exception == null){
                                                grid.reload();
                                                nui.alert("bug完成", "系统提示", function(action){
                                                    });
                                                }else{
                                                    grid.unmask();
                                                    nui.alert("bug失败", "系统提示");
                                                }
                                            }
                                            });
								}
								function openDetails(bugId) {
									nui.open({
										url: "<%=request.getContextPath()%>/xmgl/bugDetails.jsp?bugId="
								+ bugId,
						title : "bug详情",
						width : 600,
						height : 500,
					});
		}
	</script>
</body>
</html>
